/**
* Copyright 2009, Jethro Grassie, Creative Jar Technology Ltd (http://www.cjtech.co.uk)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
**/

package com.cjt.sample.commands;

import com.adobe.cairngorm.commands.Command;
import com.adobe.cairngorm.control.CairngormEvent;
import com.adobe.cairngorm.business.Responder;

import com.cjt.sample.Model;
import com.cjt.sample.business.Services;
import com.cjt.sample.business.TimeRMIService;

public class GetTimeRMICommand extends Command, Responder
{
    public override function execute(event:CairngormEvent):Void
    {
        println("Executing GetTimeRMICommand");
        var service:TimeRMIService = Services.getInstance()
            .getRMIService("getTimeRMI") as TimeRMIService;
        service.addResponder(this);
        service.getTime();
    }

    public override function onResult(data:Object):Void
    {
        var model = Model.getInstance();
        model.lastResult = data as String;
    }

    public override function onFault(data:Object):Void
    {
        var model = Model.getInstance();
        model.lastResult = data.toString();
    }
}

